package test2;

import java.util.Arrays;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        //sc.nextLine();
        Shape[]shapes = new Shape[n];
        int m=0;
        while(n>=1) {
            String s = sc.next();
            if( s.equals("rect")){
                int c = sc.nextInt();
                int k = sc.nextInt();
                Rectangle rectangle = new Rectangle(c,k);
                shapes[m++] = rectangle;
            } else {
                int r =sc.nextInt();
                Circle circle = new Circle(r);
                shapes[m++] = circle;
            }
            n--;
        }
        System.out.println(sumAllPerimeter(shapes));
        System.out.println(sumAllArea(shapes));
        System.out.println(Arrays.toString(shapes));
        for (Shape s:shapes) {
            System.out.println(s.getClass() + ","+ s.getClass().getSuperclass());
        }
    }

    public static double sumAllArea(Shape[]shapes) {
        double sum = 0;
        for (Shape s: shapes) {
            sum+= s.getArea();
        }
        return sum;
    }

    public static double sumAllPerimeter(Shape[]shapes) {
        double sum = 0;
        for (Shape s: shapes) {
            sum+= s.getPerimeter();
        }
        return sum;
    }
}
